<template>
  <div>
    <a-form-model-item label="用户名">
      <a-input v-model="form.username" placeholder="请输入用户名" />
    </a-form-model-item>

    <a-form-model-item label="密码">
      <a-input v-model="form.password" placeholder="请输入密码" />
    </a-form-model-item>

    <a-button type="primary" @click="login">
      登&emsp;录
    </a-button>
  </div>
</template>

<script>
export default {
  name: "login",
  data(){
    return{
      form:{
        username:'',
        password:'',
      }
    }
  },
  methods:{
    login(){
      let UserInfo=new FormData()
      UserInfo.append("username",this.form.username)
      UserInfo.append("password",this.form.password)
      this.$axios.post('/z/login/',UserInfo)
        .then(res=>{
          console.log(res.data.msg)
          if(res.data.code==200){
            localStorage.setItem('uid',res.data.uid)
            // alert(res.data.msg)
            this.$router.push('/index')
          }
        })

    }
  }
}
</script>

<style scoped>

</style>
